import Vue from 'vue'
import App from './App.vue'
import router from './router'
// 导入全局样式表
import './assets/css/global.css'
// 导入字体图标
import './assets/fonts/iconfont.css'
import ZkTable from 'vue-table-with-tree-grid'
import axios from 'axios'
import VueQuillEditor from 'vue-quill-editor'

import NProgress from 'nprogress'

Vue.component('tree-table', ZkTable)
axios.defaults.baseURL = 'https://www.liulongbin.top:8888/api/private/v1/'
axios.interceptors.request.use(config => {
  NProgress.start()

  // if (config.url !== 'login') {
  config.headers.Authorization = window.sessionStorage.getItem('token')
  // }
  return config
})
axios.interceptors.response.use(config => {
  NProgress.done()
  return config
})
Vue.use(VueQuillEditor /* { default global options } */)
Vue.config.productionTip = false

Vue.prototype.$http = axios
Vue.filter('dateFormat', function (date) {
  const dt = new Date(date)
  var yy = dt.getFullYear()
  var mm = (dt.getMonth() + 1 + '').padStart(2, '0')
  var dd = (dt.getDay() + '').padStart(2, '0')
  var hh = (dt.getHours() + '').padStart(2, '0')
  var ff = (dt.getMinutes() + '').padStart(2, '0')
  var ss = (dt.getSeconds() + '').padStart(2, '0')
  return `${yy}-${mm}-${dd} ${hh}:${ff}:${ss}`
})
new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
